// FileProperties.cpp : implementation file
//

#include "stdafx.h"
#include "greenftp.h"
#include "FileProperties.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFileProperties property page

IMPLEMENT_DYNCREATE(CFileProperties, CPropertyPage)

CFileProperties::CFileProperties() : CPropertyPage(CFileProperties::IDD)
{
	//{{AFX_DATA_INIT(CFileProperties)
	m_strFileName = _T("");
	m_strDate = _T("");
	m_strDescription = _T("");
	m_strGroup = _T("");
	m_strLocation = _T("");
	m_strOwner = _T("");
	m_strPermission = _T("");
	m_strSize = _T("");
	m_strType = _T("");
	m_strADate = _T("");
	m_strMDate = _T("");
	m_Archive = FALSE;
	m_Hidden = FALSE;
	m_ReadOnly = FALSE;
	m_System = FALSE;
	//}}AFX_DATA_INIT
	m_bIsDirectory = FALSE;
}

CFileProperties::~CFileProperties()
{
}

void CFileProperties::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFileProperties)
	DDX_Text(pDX, IDC_FILENAME, m_strFileName);
	DDX_Text(pDX, IDC_DATE, m_strDate);
	DDX_Text(pDX, IDC_DESCRIPTION, m_strDescription);
	DDX_Text(pDX, IDC_GROUP, m_strGroup);
	DDX_Text(pDX, IDC_LOCATION, m_strLocation);
	DDX_Text(pDX, IDC_OWNER, m_strOwner);
	DDX_Text(pDX, IDC_PERMISSION, m_strPermission);
	DDX_Text(pDX, IDC_FILE_SIZE, m_strSize);
	DDX_Text(pDX, IDC_TYPE, m_strType);
	DDX_Text(pDX, IDC_ADATE, m_strADate);
	DDX_Text(pDX, IDC_MDATE, m_strMDate);
	DDX_Check(pDX, IDC_ARCHIVE, m_Archive);
	DDX_Check(pDX, IDC_HIDDEN, m_Hidden);
	DDX_Check(pDX, IDC_READONLY, m_ReadOnly);
	DDX_Check(pDX, IDC_SYSTEM, m_System);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFileProperties, CPropertyPage)
	//{{AFX_MSG_MAP(CFileProperties)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFileProperties message handlers

void CFileProperties::GetSystemIcon()
{
	SHFILEINFO sfi;
	memset(&sfi, 0, sizeof(sfi));

	SHGetFileInfo(m_strFileName,  
			m_bIsDirectory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL, 
			&sfi, 
			sizeof(sfi), 
			SHGFI_LARGEICON | SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);
	SendDlgItemMessage(IDC_FILE_ICON, STM_SETICON, (WPARAM) sfi.hIcon, 0);

}

BOOL CFileProperties::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	GetSystemIcon();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
